home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
dirut
/
eren.zip
/
EREN.ASM
next >
Wrap
Assembly Source File
|
1985-09-06
|
3KB
|
69 lines
PAGE 72,120
TITLE SREN Change name of file, sub-dir, or Vol. ID
COMMENT * SREN [d:]name1 name2
Renames files or subdirectories from name1 to name2.
Name1 & Name2 may have extensions and wild characters.
Action of the program is as described in the DOS manual
for INT 21, Function 17.
*
COM SEGMENT
ASSUME CS:COM, DS:COM, ES:COM, SS:COM
ORG 05CH ; FCB formed from Name1
fcb1 LABEL BYTE
drive1 db ?
name1 db 11 DUP (?)
ORG 06CH ; FCB formed from name2
fcb2 LABEL BYTE
drive2 db ?
name2 db 11 DUP (?)
ORG 100H
SREN PROC
mov dx, offset invdr$ ; Point to error message
test al,al ; Test for valid drive ID
jnz error ; Xfr - invalid drive ID
mov dx,offset invpar$ ; Get pointer to next error message
cmp name1,' ' ; Check for presence of Name1
je error ; Xfr - no Name1
cmp name2,' ' ; Check for presence of Name2
je error ; Xfr - no Name2
mov si, offset fcb1 ; Get ptr to Name1 FCB
mov di, offset oldn ; Get ptr to 'old' name field
mov cx,12 ; Set move count for 12 bytes
rep movsb ; Move name1 to Extended FCB
mov si, offset name2 ; Get ptr to Name2 - not drive
mov di, offset oldn+11H ; Get ptr to 'new' name field
mov cx,11 ; Set move count for 11 bytes
rep movsb ; Move 'new' name to Extended FCB
mov dx, offset xfcb ; Get ptr to Extended FCB for DOS
mov ah,17H ; ... MS-DOS 'Rename' function
int 21H ; ... MS-DOS entry interrupt
test al,al ; Test for errors
jz exit ; Xfr - no errors - exit program
mov dx, offset invnam$ ; Get ptr to error message
error: mov ah,9 ; ... MS-DOS 'Print Message' function
int 21H ; ... MS-DOS entry interrupt
exit: int 20H ; EXIT - MS-DOS 'Terminate' interrupt
SREN ENDP
invdr$ db 0DH,0AH,'Invalid drive ID',0DH,0AH,'$'
invpar$ db 0DH,0AH,'2 Params needed- [d:]oldname newname',0DH,0AH,'$'
invnam$ db 0DH,0AH,'Name not found or already exists',0DH,0AH,'$'
xfcb db 0FFH ; Extended FCB ID byte
db 5 DUP (0)
attr db 18H ; Attr byte for sub-dirs & vol labels
oldn db 37 DUP (0) ; Old & New name fields
COM ENDS
END SREN